package com.jxau.subject.common.enums;

import lombok.Getter;

@Getter
public enum ResultCodeEnum {

    SUCCESS(200, "成功"),
    FAIL(500, "失败");

    public int code;
    public String desc;

    ResultCodeEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static ResultCodeEnum getByCode(int code) {
        for (ResultCodeEnum e : ResultCodeEnum.values()) {
            if (e.code == code) {
                return e;
            }
        }
        return null;
    }

//    public int getCode() {
//        return code;
//    }
//
//    public String getDesc() {
//        return desc;
//    }

    public static void main(String[] args) {
        ResultCodeEnum result = ResultCodeEnum.getByCode(200);
    }
}
